package 多线程.线程池;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Main {
    public static void main(String[] args) {
        //创建一个普通的线程池
        //根据任务数目，自动进行线程扩容
        ExecutorService executorService = Executors.newCachedThreadPool();

        executorService.submit(new Runnable() {

            @Override
            public void run() {
                System.out.println("hello word" +" "+ Thread.currentThread().getName());
            }
        });
        /*//创建固定线程数目的线程池
        Executors.newFixedThreadPool(4);

        //创建一个包含单个线程的线程池
        Executors.newSingleThreadExecutor();

        //创建一个固定的线程个数但是任务是延时的线程池
        Executors.newScheduledThreadPool(4);*/
    }
}
